package com.dx.architectureddd.app.event.handler;

import com.dx.architectureddd.client.dto.event.GameOverEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 游戏结束监听器
 *
 * @author xin.deng
 * @date 2023/09/24
 */
@Slf4j
@Component
public class GameOverEventListener {
    @EventListener
    @Async
    public void listenEvent(GameOverEvent event) {
        log.info("have listened the GameOverEvent");
        String reward = (String) event.getSource();
        if (reward != null) {
            log.info("玩家闯关成功！");
        } else {
            log.info("玩家闯关失败，让其充值。");
        }
    }
}
